import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.TreeMap;

public class 统计数字 {
   /* public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n = sc.nextInt();
        //创建一个Treemap集合存储数据
        TreeMap<Integer,Integer> tm=new TreeMap<>();
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            //判断数字在集合中是否存在
            if (tm.containsKey(a)){
                //获取数字对应的值
                Integer value = tm.get(a)+1;
                tm.put(a,value);
            }else {
                tm.put(a,1);
            }
        }
        tm.forEach((key,value)-> System.out.println(key+" "+value));
    }*/
    //因为System.in的底层是字节输入流,效率较低,所以转行为缓冲流提高效率.
   public static void main(String[] args) throws IOException {
       BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
       //创建一个Treemap集合存储数据
       TreeMap<Integer,Integer> tm=new TreeMap<>();
       int n = Integer.parseInt(bf.readLine());
       for (int i = 0; i < n; i++) {
           int a = Integer.parseInt(bf.readLine());
           //判断数字在集合中是否存在
           if (tm.containsKey(a)){
               //获取数字对应的值
               Integer value = tm.get(a)+1;
               tm.put(a,value);
           }else {
               tm.put(a,1);
           }
       }
       tm.forEach((key,value)-> System.out.println(key+" "+value));
   }
}